/**
 * 滑动选择器（左右）
 */
class HSliderEx extends eui.HSlider {

    track: eui.Image;
    bar: eui.Image;
    bar0: eui.Image;
    thumb: eui.Image;

    constructor() {
        super();

        this.skinName = "eui.HSliderSkin";
    }

    childrenCreated() {
        super.childrenCreated();

        this.bar.mask = this.bar0;

        this.update();

        this.addEventListener(egret.Event.COMPLETE, this.update, this);
        this.addEventListener(eui.UIEvent.CHANGE, this.update, this);
    }

    private update() {
        this.bar0.width = (this.value / this.maximum) * 253;
    }

    set enable(b: boolean) {
        this.bar.source = b ? "slider_bar_able" : "slider_bar_unable";
        this.update();
    }
}